package leetcode;

/**
 * description:
 * author:张腾
 * date:2021-06-19
 */
public class leetcode160_2 {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        if (headA==null || headB==null) return null;

        ListNode pA=headA ,pB=headB;
        while (pA!=pB){
            pA = pA==null? headB:pA.next;
            pB = pB==null? headA:pB.next;
        }
        return pA;
    }
}
